package handler.test

import org.paic.d.D

handler.get('/test/test'){req, resp ->
	String path = req.path
	if(req.query)
		path += '?' + req.query
	
	String uri = req.uri
//	uri = req.absoluteURI
	resp.end uri
}

handler.get('/wx/yoka/init/db'){req, resp ->
	def dao = D.gen()

	dao.exe('''
create table if not exists t_peizi_pay_order (
id int auto_increment primary key,
openid varchar(50),

type varchar(10), 
amount int,
amount_int int,
total_pay int,
num int,
num_multi int,

body varchar(100), 
attach varchar(100), 

trade_no varchar(32), 

status tinyint default 1, 

dd_buyed timestamp, 
dd timestamp default current_timestamp
);

create index idx_peizi_pay_order_openid on t_peizi_pay_order(openid);
create index idx_peizi_pay_order_status on t_peizi_pay_order(status);
create index idx_peizi_pay_order_trade_no on t_peizi_pay_order(trade_no);

create table if not exists t_peizi_user_info (
id int auto_increment primary key,
openid varchar(50),

name varchar(20), 
idcard_no varchar(20), 
tel varchar(11),

idcard_pic varchar(100), 
idcard_pic2 varchar(100), 

dd timestamp default current_timestamp
);

create index idx_peizi_user_info_openid on t_peizi_user_info(openid);
	'''
	)

//	dao.exe('''
//create table if not exists wx_user(
//	id int auto_increment primary key, 
//
//	openid varchar(50), 
//	nickname varchar(50),
//	sex tinyint(1), 
//
//	province varchar(50), 
//	city varchar(50),
//	headimgurl varchar(200),
//
//	dd timestamp default current_timestamp
//);
//create index idx_wx_user_openid on wx_user(openid);
//
//create table if not exists wx_user_log (
//	id int auto_increment primary key, 
//	openid varchar(50), 
//
//	type varchar(20),
//	msg varchar(50),
//
//	dd timestamp default current_timestamp
//);
//create index idx_wx_user_log_openidon on wx_user_log(openid);
//	'''
//	)

	resp.end 'ok'
}